<?xml version="1.0" encoding="UTF-8" ?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:p="http://java.sun.com/jsf/portlet/components" xmlns:c="http://java.sun.com/jstl/core_rt" version="2.0">
	<f:view>
		<p:portletPage>
			<a4j:outputPanel layout="block" styleClass="mediadoresWrapper">
				<a4j:outputPanel layout="block" styleClass="headerWrapper">
					<a4j:outputPanel layout="block" styleClass="accesible clearfix"></a4j:outputPanel>
				</a4j:outputPanel>
				<a4j:outputPanel layout="block" styleClass="topMenuWrapper">
					<h:form>
						<a4j:outputPanel>
							<a4j:commandLink value="Volver" action="#{InsurancePoliciesManagement.deleteFilter}" immediate="true" styleClass="topMenuLink" />
						</a4j:outputPanel>
						<a4j:outputPanel>
							<a4j:commandLink value="Alta de nota informativa" onclick="showInsurancePolicyDetail(0,1)" styleClass="topMenuLink" rendered="#{InsurancePoliciesManagement.newSimulationLinkRendered}" />
						</a4j:outputPanel>
						<a4j:outputPanel>
							<a4j:commandLink value="Alta de solicitud de póliza" onclick="showInsurancePolicyDetail(0,2)" styleClass="topMenuLink" rendered="#{InsurancePoliciesManagement.newRequestLinkRendered}" />
						</a4j:outputPanel>
					</h:form>
				</a4j:outputPanel>
				<a4j:outputPanel layout="block" styleClass="contentWrapper">
					<a4j:outputPanel layout="block" styleClass="titleWrapper">
						<h:outputText value="Gestión de pólizas" />
					</a4j:outputPanel>
					<rich:panel header="Criterios de búsqueda">
						<h:form id="searchParametersForm">
							<a4j:outputPanel layout="block" id="filtros">
								<h:panelGrid columns="8" border="0" rules="none">
									<h:outputText value="NIF Tomador: " />
									<h:inputText value="#{InsurancePoliciesManagement.NIFTomador}" styleClass="textField" />
									<rich:spacer width="10" />
									<h:outputText value="NIF Asegurado: " />
									<h:inputText value="#{InsurancePoliciesManagement.NIFAsegurado}" styleClass="textField" />
									<rich:spacer width="10" />
									<h:outputText value="NIF Beneficiario: " />
									<h:inputText value="#{InsurancePoliciesManagement.NIFBeneficiario}" styleClass="textField" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<rich:spacer height="5" />
									<h:outputText value="Fecha de Alta: " />
									<rich:calendar timeZone="#{ApplicationConfiguration.serverTimeZone}" value="#{InsurancePoliciesManagement.fechaAlta}" mode="client" popup="true" datePattern="dd-MM-yyyy" enableManualInput="false" showApplyButton="false" locale="es_ES" />
									<rich:spacer />
									<rich:spacer />
									<rich:spacer />
									<rich:spacer />
									<rich:spacer />
									<rich:spacer />
								</h:panelGrid>
								<rich:spacer height="10" />
								<h:panelGrid columns="7" border="0" rules="none">
									<h:outputText value="Búsqueda entre fechas: " />
									<rich:spacer width="10" />
									<h:outputText value="Inicio: " />
									<rich:calendar timeZone="#{ApplicationConfiguration.serverTimeZone}" value="#{InsurancePoliciesManagement.fechaInicio}" mode="client" popup="true" datePattern="dd-MM-yyyy" enableManualInput="false" showApplyButton="false" locale="es_ES" />
									<rich:spacer width="10" />
									<h:outputText value="Fin: " />
									<rich:calendar timeZone="#{ApplicationConfiguration.serverTimeZone}" value="#{InsurancePoliciesManagement.fechaFin}" mode="client" popup="true" datePattern="dd-MM-yyyy" enableManualInput="false" showApplyButton="false" locale="es_ES" />
								</h:panelGrid>
								<rich:spacer height="10" />
								<h:panelGrid columns="5" border="0" rules="none" rendered="#{ApplicationAuthenticatedUser.applicationAuthenticatedUser.role.internalID eq '3'}">
									<h:outputText value="Usuario mediador: " />
									<h:selectOneMenu id="id_users" value="#{InsurancePoliciesManagement.IDMediador}">
										<f:selectItems value="#{InsurancePoliciesManagement.usersListBoxItems}" />
									</h:selectOneMenu>
									<rich:spacer width="10" />
									<h:outputText value="Grupo de mediadores: " />
									<h:selectOneMenu id="id_usersGroups" value="#{InsurancePoliciesManagement.IDGrupoMediador}">
										<f:selectItems value="#{InsurancePoliciesManagement.groupsListBoxItems}" />
									</h:selectOneMenu>
								</h:panelGrid>
							</a4j:outputPanel>
							<a4j:outputPanel layout="block" styleClass="richPanelButtons">
								<a4j:commandButton action="#{InsurancePoliciesManagement.filterResultsTable}" value="Filtrar" styleClass="richButton" />
							</a4j:outputPanel>
							<a4j:outputPanel layout="block" styleClass="accesible clearfix"></a4j:outputPanel>
						</h:form>
					</rich:panel>
					<rich:spacer height="10" />
					<a4j:outputPanel id="resultados" rendered="#{InsurancePoliciesManagement.tablaResultados}">
						<h:form id="searchResultsForm">
							<rich:panel header="Resultados de la búsqueda">
								<rich:datascroller id="insurancePoliciesDataScroller" for="insurancePoliciesDataTable" binding="#{InsurancePoliciesManagement.tableDataScroller}" />
								<br />
								<rich:dataTable id="insurancePoliciesDataTable" value="#{InsurancePoliciesManagement.tableDataModel}" var="item" rows="10" onRowDblClick="showInsurancePolicyDetail(#{item.internalID},0)" columnClasses="minWidthColumn noWrapColumn centerAlignText,minWidthColumn noWrapColumn rightAlignText,minWidthColumn noWrapColumn,minWidthColumn noWrapColumn,maxWidthColumn noWrapColumn,minWidthColumn noWrapColumn centerAlignText,minWidthColumn noWrapColumn centerAlignText,minWidthColumn noWrapColumn centerAlignText,minWidthColumn noWrapColumn rightAlignText" rowClasses="selectableRow">
									<rich:column>
										<f:facet name="header">
											<rich:spacer />
										</f:facet>
										<h:selectBooleanCheckbox value="#{InsurancePoliciesManagement.selectedItems[item.internalID]}" id="selectedItem" onclick="checkAllCheckboxesInTable( this.id, this.checked );" />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="ID Póliza" />
										</f:facet>
										<h:outputText value="#{item.internalID}" />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="ID PURIVEL" />
										</f:facet>
										<h:outputText value="#{empty item.externalID ? 'N/D' : item.externalID}" />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="NIF del tomador" />
										</f:facet>
										<h:outputText value="#{item.policyHolderSubjects[0].nif}" />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="Nombre del tomador" />
										</f:facet>
										<h:outputText value="#{item.policyHolderSubjects[0].surname1} #{item.policyHolderSubjects[0].surname2}, #{item.policyHolderSubjects[0].name} " />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="Fecha de alta" />
										</f:facet>
										<h:outputText value="#{empty (item.requestDate) ? item.simulationDate : item.requestDate}">
											<f:convertDateTime pattern="dd-MM-yyyy" />
										</h:outputText>
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="Estado" />
										</f:facet>
										<h:outputText value="#{item.insurancePolicyStatus.name}" />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="Forma de pago" />
										</f:facet>
										<h:outputText value="#{item.insurancePolicyPaymentType.name}" />
									</rich:column>
									<rich:column>
										<f:facet name="header">
											<h:outputText value="Cuota" />
										</f:facet>
										<a4j:outputPanel>
											<h:outputText value="#{item.share}">
												<f:convertNumber pattern="#,##0.00" />
											</h:outputText>
											<h:outputText value=" €" />
										</a4j:outputPanel>
									</rich:column>
								</rich:dataTable>
								<a4j:jsFunction name="showInsurancePolicyDetail" action="#{InsurancePolicyDetailManagement.prepareView}">
									<a4j:actionparam name="currentInsurancePolicyID" assignTo="#{InsurancePolicyDetailManagement.currentInsurancePolicyID}" />
									<a4j:actionparam name="currentInsurancePolicyGeneration" assignTo="#{InsurancePolicyDetailManagement.currentInsurancePolicyGeneration}" />
								</a4j:jsFunction>
								<a4j:outputPanel layout="block" styleClass="richTableButtons">
									<a4j:commandButton actionListener="#{InsurancePoliciesManagement.exportExcel}" value="Exportar" styleClass="richButton" />
									<a4j:commandButton actionListener="#{InsurancePoliciesManagement.print}" value="Imprimir" styleClass="richButton" />
								</a4j:outputPanel>
								<a4j:outputPanel layout="block" styleClass="accesible clearfix"></a4j:outputPanel>
							</rich:panel>
						</h:form>
					</a4j:outputPanel>
				</a4j:outputPanel>
				<a4j:outputPanel layout="block" styleClass="footerWrapper">
					<a4j:outputPanel layout="block" styleClass="accesible clearfix"></a4j:outputPanel>
				</a4j:outputPanel>
			</a4j:outputPanel>
		</p:portletPage>
	</f:view>
</jsp:root>